Skip to content

ClickTrigger

Inherits Instance

ClickTrigger lets a Physical object respond to mouse clicks and hovers. Parent it to a Physical to make that object clickable. It fires the Clicked event on the client that clicked it, with respect for the activation distance and an optional cooldown.

Example usage:

local trigger = workspace.Door.ClickTrigger
trigger.Clicked:Connect(function(player)
  print(player.Name .. " opened the door")
end)

Properties

MaxActivationDistance : number

How close (in studs) a player must be to click this object. Set to 0 to disable the distance check.

Enabled : boolean

Whether the trigger reacts to clicks and hovers.

HoverCursor : HoverCursor

The mouse cursor shown while hovering the object.

ClickCooldown : number

Minimum time (in seconds) between two clicks. 0 means no cooldown.

IsOnCooldown : boolean

Returns true while the trigger is waiting out its ClickCooldown.

Events

Clicked

Parameters: ``

Fires when a player clicks the object within range.

HoverEntered

Parameters: ``

Fires on the local client when the mouse starts hovering the object.

HoverLeft

Parameters: ``

Fires on the local client when the mouse stops hovering the object.